#include<iostream>
using namespace std;
const int N = 1e8 + 10;
int w[3], v[3];
int f[N];
int main()
{
	int n;
	cin >> n;
	w[1] = 1000, v[1] = 500;
	w[2] = 5, v[2] = 5;
	for (int i = 1; i <= 2; i++) {
		for (int j = v[i]; j <= n; j++) {
			f[j] = max(f[j], f[j - v[i]] + w[i]);
		}
	}
	cout << f[n] << endl;
	return 0;
}